package com.lagou.dao;

import com.lagou.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class UserDao {

    @Autowired
    JdbcTemplate jdbcTemplate;

    public User login(String userName, String passWord) {
        String sql = "select * from user where username = ? and password = ?";
        List<User> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(User.class), userName, passWord);
        return list != null && list.size() > 0 ? list.get(0) : null;
    }
}